package com.tlgen.spring.controller;


import com.tlgen.spring.annotation.Autowired;
import com.tlgen.spring.annotation.RestController;
import com.tlgen.spring.annotation.Value;
import com.tlgen.spring.config.MyConfig;
import com.tlgen.spring.utils.SpeedSpringContextUtils;
import com.tlgen.tomcat.annotation.GetMapping;
import com.tlgen.tomcat.comon.R;
import com.tlgen.spring.service.SysUserService;

@RestController
public class SysUserController {

    @Value("${api.transport.gis.url}")
    private String gisUrl;

    @Autowired
    private SysUserService userService;

    @GetMapping("/hello")
    public R hello() {
        MyConfig myConfig = SpeedSpringContextUtils.getBean(MyConfig.class);
        System.out.println(myConfig.name);
        return R.ok(myConfig.name);
    }

    @GetMapping("/test")
    public R test() {
        SysUserController userControllerBean = SpeedSpringContextUtils.getBean(SysUserController.class);
        System.out.println(userControllerBean.gisUrl);
        System.out.println(gisUrl); // 这个值怎么拿, 在反射调用该类的时候, 把该类的 bean 对象获取过来就有值了, 配合 tomcat 获取请求类时的扫描类逻辑, speed-tomcat 已支持
        SysUserService userServiceBean = SpeedSpringContextUtils.getBean(SysUserService.class);
        String test = userServiceBean.test();
        System.out.println(test);
        return R.ok(test);
    }

    @GetMapping("/test2")
    public R test2() {
        String test = userService.test();
        System.out.println(test);
        return R.ok(test);
    }

}
